// $URL: http://mingw-lib.googlecode.com/svn/trunk/c-drive/mingw-lib/library/t_yt_dump_lib/t_youtube_dump_lib.h $
// $Rev: 817 $
// $Author: akio.miyoshi $
// $Date:: 2013-01-21 08:47:18 +0000#$

#ifndef T_YOUTUBE_DUMP_LIB_H
#define T_YOUTUBE_DUMP_LIB_H

#include <QtCore>
#include <QSqlDatabase>
#include "t_core/nbr.h"

class T_Youtube_Video_Info
{
public:
    QString f_id;
    QStringList f_error_list;
    QMap<int, QUrl> f_fmt_map;
    QString f_title;
    QMap<int, QString> f_fmt_size_map;
};


class T_Youtube_Dump_Lib
{
public:
    explicit T_Youtube_Dump_Lib();
    static QSqlDatabase getDumpDatabase();
    static void getDownloadExe(QFile &a_file);
    static QString getVideoStreamMap(
            QNetworkAccessManager *a_nam, QString a_id, QMap<int, QUrl> &a_fmt_map, QStringList &a_error_list);
    static QString getVideoInfo(
            QNetworkAccessManager *a_nam, QString a_id, T_Youtube_Video_Info *a_video_info);
    static QString getFFMpegExe();
    static QString getToolsExe(const QString &a_exe_name, bool a_quote = false);
protected:
    static QByteArray batchGet(QNetworkAccessManager *a_nam, const QString &a_url)
    {
        T_NetworkBatch v_nbat(a_nam);
        QNetworkReply *v_reply = v_nbat.get(a_url);
        QByteArray v_result = v_reply->readAll();
        v_reply->deleteLater();
        return v_result;
    }
};

#endif // T_YOUTUBE_DUMP_LIB_H
